// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using System.Reflection;
using System.Resources;
using JetBrains.Annotations;

namespace SnapObjects.Data
{
    public static class DataStrings
    {
        private static readonly ResourceManager _resourceManager
            = new ResourceManager("SnapObjects.Data.DataStrings", typeof(DataStrings).GetTypeInfo().Assembly);

        /// <summary>
        ///     No value provided for required parameter '{parameter}'.
        /// </summary>
        public static string MissingParameterValue([CanBeNull] object parameter)
        {
            return String.Format(
                           GetString("MissingParameterValue", nameof(parameter)),
                           parameter);
        }

        private static string GetString(string name, params string[] formatterNames)
        {
            var value = _resourceManager.GetString(name);
            for (var i = 0; i < formatterNames.Length; i++)
            {
                value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
            }

            return value;
        }
    }
}
